// CommonOrderStatus
export const CommonOrderStatus = {
    WaitReview: { name: '等待审核', code: 0 },
    Passed: { name: '已审核', code: 1 },
    Unkown: { name: '未知', code: -1 },

    fromCode(code) {
        return Object.values(CommonOrderStatus).find(item => item.code === code) || CommonOrderStatus.Unkown;
    }
};
// 委外加工状态
export const ContractManufacturingStatus = {
    Draft: { name: '草稿单据', code: 0 },
    Working: { name: '加工中', code: 1 },
    Finished: { name: '加工完成', code: 2 },  
    Unkown: { name: '未知', code: -1 },

    fromCode(code) {
        return Object.values(ContractManufacturingStatus).find(item => item.code === code) || ContractManufacturingStatus.Unkown;
    }
};

// DocType
export const DocType = {
    DCKD: { name: '待出库单', code: 0 },
    DRKD: { name: '待入库单', code: 1 },
    CKD: { name: '出库单', code: 2 },
    RKD: { name: '入库单', code: 3 },
    XSD: { name: '销售单', code: 4 },
    CGD: { name: '采购单', code: 5 },
    YFKD: { name: '应付款单', code: 6 },
    FKD: { name: '付款单', code: 7 },
    YSKD: { name: '应收款单', code: 8 },
    SKD: { name: '收款单', code: 9 },
    XSTHD: { name: '销售退货单', code: 10 },
    CGTHD: { name: '采购退货单', code: 11 },
    PreSKD: { name: '预收款单', code: 12 },
    PreFKD: { name: '预付款单', code: 13 },
    ZFKD: { name: '其他支出单', code: 14 },
    ZSKD: { name: '其他收入单', code: 15 },
    PDD: { name: '盘点单', code: 16 },
    DBD: { name: '调拨单', code: 17 },
    YSD_TASK: { name: '银行支付', code: 18 },
    YFD_TASK: { name: '应付单', code: 19 },
    COST_ADJ: { name: '成本调整单', code: 20 },
    QUOTATION: { name: '销售报价单', code: 21 },
    ASSEMBLER: { name: '组装拆卸单', code: 22 },
    RETAIL: { name: '零售单', code: 23 },
    StatementOrder: { name: '对账单', code: 24 },
    INIT_FUND_PENDING_Order: { name: '初始欠款单', code: 25 },
    METAL_REFINE: { name: '贵金属加工单', code: 26 },
    METAL_COMBINE: { name: '贵金属业务单', code: 27 },
    PERIOD_SETTLEMENT: { name: '结算单', code: 28 },
    Unknown: { name: '未知', code: -1 },

    fromCode(code) {
        return Object.values(DocType).find(item => item.code === code) || DocType.Unknown;
    }
};

// OperationCode
export const OperationCode = {
    QCSD: { name: '期初设定', code: 0 },
    PDSD: { name: '盘点单库存设定', code: 1 },
    ZZCXCK: { name: '组装拆卸出库', code: 2 },
    ZZCXRK: { name: '组装拆卸入库', code: 3 },
    GHCK: { name: '归还出库', code: 4 },
    BSCK: { name: '报损出库', code: 5 },
    PDCK: { name: '盘点出库', code: 6 },
    LLCK: { name: '领料出库', code: 7 },
    DBCK: { name: '调拨出库', code: 8 },
    CGTHCK: { name: '采购退货出库', code: 9 },
    QTRK: { name: '其他入库', code: 10 },
    GHRK: { name: '归还入库', code: 11 },
    JYRK: { name: '借用入库', code: 12 },
    PDRK: { name: '盘点入库', code: 13 },
    DBRK: { name: '调拨入库', code: 14 },
    XSTHRK: { name: '销售退货入库', code: 15 },
    QCRK: { name: '期初入库', code: 16 },
    HGRK: { name: '回购入库', code: 17 },
    XSRK: { name: '采购入库', code: 18 },
    HGCK: { name: '回购出库', code: 19 },
    XSCK: { name: '销售出库', code: 20 },

    fromCode(code) {
        return Object.values(OperationCode).find(item => item.code === code) || OperationCode.QCSD;
    }
};

// ProgressState
export const ProgressState = {
    None: { name: '无进度', code: 0 },
    PartDone: { name: '部分完成', code: 1 },
    AllDone: { name: '全部完成', code: 2 },

    fromCode(code) {
        return Object.values(ProgressState).find(item => item.code === code) || ProgressState.None;
    }
};

// OrderSortType
export const OrderSortType = {
    CreateTime: { name: '创建时间排序', code: 0 },
    OperationTime: { name: '业务时间排序', code: 1 },

    fromCode(code) {
        return Object.values(OrderSortType).find(item => item.code === code) || OrderSortType.CreateTime;
    }
};

// QuotationPlacedState
export const QuotationPlacedState = {
    All: { name: '所有', code: 0 },
    Placed: { name: '已下单', code: 1 },
    NotPlaced: { name: '未下单', code: 2 },

    fromCode(code) {
        return Object.values(QuotationPlacedState).find(item => item.code === code) || QuotationPlacedState.All;
    }
};

// ThirdpartyType
export const ThirdpartyType = {
    Unknown: { name: '未知', code: 0 },
    WechatPay: { name: '微信支付', code: 1 },
    AliPay: { name: '阿里支付', code: 2 },
    Bank: { name: '银行支付', code: 3 },

    fromCode(code) {
        return Object.values(ThirdpartyType).find(item => item.code === code) || ThirdpartyType.Unknown;
    }
};

// ChargeOrderSourceCode
export const ChargeOrderSourceCode = {
    Unknown: { name: '未知', code: 0 },
    Merchant: { name: '商户', code: 1 },
    Proxy: { name: '代理商', code: 2 },
    Platform: { name: '平台', code: 3 },

    fromCode(code) {
        return Object.values(ChargeOrderSourceCode).find(item => item.code === code) || ChargeOrderSourceCode.Unknown;
    }
};

// ChargeOrderType
export const ChargeOrderType = {
    Unknown: { name: '未知', code: 0 },
    PkgCharge: { name: '套餐续费', code: 1 },
    AccountCharge: { name: '账户续费', code: 2 },

    fromCode(code) {
        return Object.values(ChargeOrderType).find(item => item.code === code) || ChargeOrderType.Unknown;
    }
};

// ChargeOrderStatus
export const ChargeOrderStatus = {
    UNPAYED: { name: '未付款', code: 0 },
    PAYED: { name: '已付款', code: 1 },
    FREECHARGED: { name: '免单支付', code: 2 },

    fromCode(code) {
        return Object.values(ChargeOrderStatus).find(item => item.code === code) || ChargeOrderStatus.UNPAYED;
    }
};

// PlPackageStatus
export const PlPackageStatus = {
    Unknown: { name: '未知', code: 0 },
    ENABLE: { name: '启用', code: 1 },
    DISABLE: { name: '弃用', code: 2 },

    fromCode(code) {
        return Object.values(PlPackageStatus).find(item => item.code === code) || PlPackageStatus.Unknown;
    }
};

// OrderInventoryHandleMethod
export const OrderInventoryHandleMethod = {
    QuickInventory: { name: '直接出入库', code: 0 },
    WaitInventory: { name: '待出入库', code: 1 },
    InventoryBySetting: { name: '单据中询问', code: 2 },

    fromCode(code) {
        return Object.values(OrderInventoryHandleMethod).find(item => item.code === code) || OrderInventoryHandleMethod.QuickInventory;
    }
};

// OrderResultCategoryType
export const OrderResultCategoryType = {
    Fund: { name: '资金变化', code: 0 },
    PendingInventoryIn: { name: '待入库变化', code: 1 },
    PendingInventoryOut: { name: '待出库变化', code: 2 },
    Inventory: { name: '库存变化', code: 3 },
    Unknown: { name: '未知变化', code: 4 },

    fromCode(code) {
        return Object.values(OrderResultCategoryType).find(item => item.code === code) || OrderResultCategoryType.Unknown;
    }
};

// OrderResultCategoryItemType
export const OrderResultCategoryItemType = {
    FundAccount: { name: '账户', code: 0 },
    ReceiveDebt: { name: '应收欠款', code: 1 },
    PaymentDebt: { name: '应付欠款', code: 2 },
    PreReceiveAccount: { name: '预收账户', code: 3 },
    PrePaymentAccount: { name: '预付账户', code: 4 },
    CommodityInventory: { name: '商品', code: 5 },
    Unknown: { name: '未知', code: 6 },

    fromCode(code) {
        return Object.values(OrderResultCategoryItemType).find(item => item.code === code) || OrderResultCategoryItemType.Unknown;
    }
};

// TimeFilterItemType
export const TimeFilterItemType = {
    Today: { name: '今天', code: 0 },
    YesterDay: { name: '昨天', code: 1 },
    LatestSevenDays: { name: '近7日', code: 2 },
    LatestThirtyDays: { name: '近30日', code: 3 },
    ThisMonth: { name: '本月', code: 4 },
    LastMonth: { name: '上月', code: 5 },
    SelfDefine: { name: '自定义', code: 6 },

    fromCode(code) {
        return Object.values(TimeFilterItemType).find(item => item.code === code) || TimeFilterItemType.Today;
    }
};

// 混合单据类型
export const CombineOrderType = {
    NormalRnd: Object.freeze({ name: '普通单据', code: 1 }),
    SettledRnd: Object.freeze({ name: '结算单据', code: 2 }),
    PeriodInitalRnd: Object.freeze({ name: '期初单据', code: 3 }),
    Unknown: Object.freeze({ name: '未知', code: -1 }),

    fromCode(code) {
        return Object.values(CombineOrderType).find(item => item.code === code) || CombineOrderType.Unknown;
    }
};
